﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Mvc;
using ToWaTimeReportMVC4.Models;

namespace ToWaTimeReportMVC4
{
    /// <summary>
    /// Summary description for ToWaWS
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class ToWaWS : System.Web.Services.WebService
    {
        ToWaService service = new ToWaService();

        [WebMethod]
        public void AddConsultantToJob(User consultant, Job job)
        {
            service.AddConsultantToJob(consultant, job);
        }

        [WebMethod]
        public void AddJob(DateTime startTime, DateTime endTime, string description, int projectId, int consultantId)
        {
            service.AddJob(startTime, endTime, description, projectId, consultantId);
        }

        [WebMethod]
        public void AddJobFromJobView(JobView jobView, int consultantId)
        {
            service.AddJobFromJobView(jobView, consultantId);
        }

        [WebMethod]
        public void AddProject(string name, int costumerId, string description)
        {
            service.AddProject(name, costumerId, description);
        }
        [WebMethod]
        public void AddUser(string username, string password, string salt, string email, int type, int salary, int hoursWorked)
        {
            service.AddUser(username, password, salt, email, type, salary, hoursWorked);
        }

        [WebMethod]
        public List<UserProjectWrapper> GetAdminIndexList()
        {
            return service.GetAdminIndexList();
        }

        [WebMethod]
        public List<User> GetAllConsultant()
        {
            return service.GetAllConsultant();
        }

        [WebMethod]
        public List<User> GetAllCustomers()
        {
            return service.GetAllCustomers();
        }

        [WebMethod]
        public float GetBelaggningsGradFroConsultant(User consultant, int belaggningsgrad)
        {
           return service.GetBelaggningsGradForConsultant(consultant, belaggningsgrad);
        }

        [WebMethod]
        public List<SelectListItem> GetConsultantDropDown()
        {
            return service.GetConsultantDropDown();
        }

        [WebMethod]
        public List<ConsultantWrapper> GetConsultantWorkedHoursByProjectId(int id, DateTime start, DateTime end)
        {
            return service.GetConsultantsWorkedHoursByProjectId(id, start, end);
        }

        [WebMethod]
        public Job GetJobById(int id)
        {
            return service.GetJobById(id);
        }

        [WebMethod]
        public string GetJobDescriptionByJobId(int id)
        {
            return service.GetJobDescriptionByJobId(id);
        }

        [WebMethod]
        public List<Job> GetJobsByConsultantId(int id)
        {
            return service.GetJobsByConsultantId(id);
        }

        [WebMethod]
        public List<JobView> GetJobViewList(string username)
        {
            return service.GetJobViewList(username);
        }

        [WebMethod]
        public Project GetProjectById(int id)
        {
            return service.GetProjectById(id);
        }

        [WebMethod]
        public int GetProjectCost(int id)
        {
            return service.GetProjectCost(id);
        }

        [WebMethod]
        public int GetProjectCostBetweenDates(int id, DateTime start, DateTime end)
        {
            return service.GetProjectCostBetweenDates(id, start, end);
        }

        [WebMethod]
        public List<Project> GetProjectsByConsultant(User consultant, DateTime from, DateTime to)
        {
            return service.GetProjectsByConsultant(consultant, from, to);
        }

        [WebMethod]
        public List<ProjectWrapper> GetProjectsByCustomerId(int id)
        {
            return service.GetProjectsByCustomerId(id);
        }

        [WebMethod]
        public List<SelectListItem> GetProjectsDropDown()
        {
            return service.GetProjectsDropDown();
        }

        [WebMethod]
        public Rapport GetRapportForConsultant(string username, string startTime, string endTime, int normal)
        {
            return service.GetRapportForConsultant(username, startTime, endTime, normal);
        }

        [WebMethod]
        public Rapport GetRapportForConsultant(int consultantId, string startTime, string endTime, int normal)
        {
            return service.GetRapportForConsultant(consultantId, startTime, endTime, normal);
        }

        [WebMethod]
        public string GetTypeOfUserByUsername(string username)
        {
            return service.GetTypeOfUserByUsername(username);
        }

        [WebMethod]
        public User GetUserById(int id)
        {
            return service.GetUserById(id);
        }

        [WebMethod]
        public User GetUserByUsername(string username)
        {
           return service.GetUserByUsername(username);
        }

        [WebMethod]
        public bool RemoveProjectById(int id)
        {
            return service.RemoveProjectById(id);
        }

        [WebMethod]
        public bool RemoveUserById(int id)
        {
            return service.RemoveUserById(id);
        }

        [WebMethod]
        public User ValidateUser(string username, string password)
        {
            return service.ValidateUser(username, password);
        }
    }
}
